<?php
//joker
declare(strict_types=1);

namespace app\store\controller\user;

use app\store\controller\Controller;
use app\store\service\user\AdminPrize as UserAdminPrize;
use app\store\validate\AdminPrize as ValidateAdminPrize;
use think\facade\Request;

/**
 * 管理员奖配置
 * Class User
 * @package app\store\controller
 */
class AdminPrize extends Controller
{
    /**
     * 获取配置信息
     * @return json
     * @throws \think\db\exception\DbException
     */
    public function get()
    {
    }

    /**
     * 设置管理员奖
     * @return json
     */
    public function save()
    {
        if (!Request::isPost())
            return $this->renderError('请求方式错误');
        //接收参数post
        $param = array(
            'upgrade' => Request::param('upgrade/a', []),
            'prize' => Request::param('prize/a', [])
        );
        $validate = new ValidateAdminPrize();
        if (!$validate->scene('save')->check($param))
            return $this->renderError($validate->getError());
        UserAdminPrize::save($param);
        return $this->renderSuccess();
    }
}
